package com.bw.mapper;

import com.bw.bean.Vo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface VoMapper {
    @Select("select\n" +
            "    c.name,\n" +
            "    sum(oi.final_total_amount) `value`\n" +
            "from order_info oi\n" +
            "left join order_detail od on oi.id = od.order_id\n" +
            "left join sku_info si on od.sku_id = si.id\n" +
            "left join spu_info s on si.spu_id = s.id\n" +
            "left join base_category3 b on si.category3_id = b.id\n" +
            "left join base_category2 c on b.category2_id = c.id\n" +
            "group by c.name")
    List<Vo> getList1();

    @Select("select\n" +
            "    bt.name,\n" +
            "    sum(oi.final_total_amount) `value`\n" +
            "from order_info oi\n" +
            "left join order_detail od on oi.id = od.order_id\n" +
            "left join sku_info si on od.sku_id = si.id\n" +
            "left join base_trademark bt on si.tm_id = bt.id\n" +
            "group by bt.name\n" +
            "order by `value`")
    List<Vo> getList2();

    @Select("call proc1()")
    double getList3();

    @Select("select\n" +
            "    s.spu_name `name`,\n" +
            "    sum(oi.final_total_amount) `value`\n" +
            "from order_info oi\n" +
            "left join order_detail od on oi.id = od.order_id\n" +
            "left join sku_info si on od.sku_id = si.id\n" +
            "left join spu_info s on si.spu_id = s.id\n" +
            "group by s.spu_name")
    List<Vo> getList4();
}
